package lsl.leetCode.year2023.test0303;

/**
 * description:
 *
 * @author: liushengli
 * data: 2023/3/3
 */
public class test415 {
    public static void main(String[] args) {

    }

    public static String addStrings(String num1, String num2) {
        int length1 = num1.length() - 1;
        int length2 = num2.length() - 1;
        StringBuffer buffer = new StringBuffer();
        int add = 0;
        while (length1 >= 0 || length2 >= 0 || add != 0) {
            int a = length1 >= 0 ? num1.charAt(length1) - '0' : 0;
            int b = length2 >= 0 ? num2.charAt(length2) - '0' : 0;
            int sum = a + b + add;
            buffer.append((sum % 10));
            add = sum / 10;
            length1--;
            length2--;
        }
        buffer.reverse();
        return buffer.toString();
    }
}
